/**
 * Created by Administrator on 2018/8/9.
 */
function logout(){
    $.post("/index/Login/logout","",function(e){
        window.location.href="/index/Login/index";
    });
}

$(function(){
	//console.log(111);
	
	$(".select_hour").change(function(){
		$("input[name=doctor]").each(function(){
			$(this).attr("disabled",false); 
			$(this).next().css("color","#555");
		});
		$("select[name=zhiliaoshi] option").each(function(){
			$(this).attr("disabled",false); 
			$(this).css("color","#555");
		});
		$("input[name=device]").each(function(){
			$(this).attr("disabled",false); 
			$(this).next().css("color","#555");
		});
		
		$("input[name=meirongshi]").each(function(){
			$(this).attr("disabled",false); 
			$(this).next().css("color","#555");
		});
		
		$("input[name=position]").each(function(){
			$(this).attr("disabled",false); 
			$(this).next().css("color","#555");
		});
		
		
		
		time = ($(".time_hour").val())+":"+($(".time_min").val());        //治疗时间 几点钟
		date = $("#laydateInput").val();
	
		$.post("/index/Set/testtt",{"date":date,"time":time},function(e){
			obj = eval('(' + e + ')');
			doctor_arr = obj.doctor_arr;
			zhiliaoshi_arr = obj.zhiliaoshi;
			shebei_arr = obj.shebei_arr;
			nurse_arr = obj.nurse_arr;
			item_arr = obj.project_arr;
			console.log(obj);
			//设置医生不可选
			for(i=0;i<doctor_arr.length;i++){
				$("input[name=doctor]").each(function(){
					if($.trim($(this).val()) == $.trim(doctor_arr[i])){
						
						$(this).attr("disabled","disabled"); 
						$(this).next().css("color","#ded7d7");
					}
				});
			}
			//设置治疗室
			for(j=0;j<zhiliaoshi_arr.length;j++){
				$("select[name=zhiliaoshi] option").each(function(){
					str = $.trim($(this).val());
					zhiliaoshi = $.trim(zhiliaoshi_arr[j])
					regExp=new RegExp(zhiliaoshi);					
					if(regExp.test(str)){
						$(this).attr("disabled","disabled"); 
						$(this).css("color","red");
					}
				});
			}
			
			//设置美容医生
			for(j=0;j<nurse_arr.length;j++){
				$("input[name=meirongshi]").each(function(){
					str = $.trim($(this).val());
					shebei = $.trim(nurse_arr[j])
					regExp=new RegExp(shebei);
					
					if(regExp.test(str)){
						
						$(this).attr("disabled","disabled"); 
						$(this).next().css("color","#ded7d7");
					}
				});
			}
			
			//设置项目
			for(j=0;j<item_arr.length;j++){
				$("input[name=position]").each(function(){
					str = $.trim($(this).val());
					if(str == item_arr[j]){
						$(this).attr("disabled","disabled"); 
						$(this).next().css("color","#ded7d7");
					}
				});
			}
			//设置设备
			for(j=0;j<shebei_arr.length;j++){
				$("input[name=device]").each(function(){
					str = $.trim($(this).val());
					

					if(str == shebei_arr[j]){
						
						$(this).attr("disabled","disabled"); 
						$(this).next().css("color","#ded7d7");
					}
				});
			}
			
			
		});
	});
	$(".select_min").change(function(){
		$("input[name=doctor]").each(function(){
			$(this).attr("disabled",false); 
			$(this).next().css("color","#555");
		});
		time = ($(".time_hour").val())+":"+($(".time_min").val());        //治疗时间 几点钟
		date = $("#laydateInput").val();
		console.log(time);
		console.log(date);
		
		$.post("/index/Set/testtt",{"date":date,"time":time},function(e){
			obj = eval('(' + e + ')');
			doctor_arr = obj.doctor_arr;
			console.log(doctor_arr);
			for(i=0;i<doctor_arr.length;i++){
				$("input[name=doctor]").each(function(){
				
					if($.trim($(this).val()) == $.trim(doctor_arr[i])) {
						console.log($.trim($(this).val()));
						$(this).attr("disabled","disabled"); 
						$(this).next().css("color","#ded7d7");
					}else{
						$(this).attr('checked',false);
					}
				});
			}
		});
	});

});
